//
//  ReadCacheTool.m
//  TakeYouTourTogether
//
//  Created by dllo on 15/12/7.
//  Copyright © 2015年 king. All rights reserved.
//

#import "ReadCacheTool.h"

@implementation ReadCacheTool
+ (void)isHaveFilder {
    NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    // 创建管理者
    NSFileManager *manager = [NSFileManager defaultManager];
    NSString *cachesDocPath = [sandBoxPath stringByAppendingPathComponent:@"TYTT"];
    if (![manager fileExistsAtPath:cachesDocPath]) {
        [manager createDirectoryAtPath:cachesDocPath withIntermediateDirectories:YES attributes:nil error:nil];
    }
}

+ (void)saveModel:(NSMutableArray *)array toPlist:(NSString *)plistPath {
    NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    NSString *cachesDocPath = [sandBoxPath stringByAppendingPathComponent:[NSString stringWithFormat:@"TYTT/%@", plistPath]];
    [NSKeyedArchiver archiveRootObject:array toFile:cachesDocPath];
//    NSLog(@"~~~~~~~~~abc~~~~~~~~%@", cachesDocPath);
}
+ (NSMutableArray *)getModelInPlist:(NSString *)plistPath {
    NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    NSString *cachesDocPath = [sandBoxPath stringByAppendingPathComponent:[NSString stringWithFormat:@"TYTT/%@", plistPath]];
    NSMutableArray *mArray = [NSKeyedUnarchiver unarchiveObjectWithFile:cachesDocPath];
//    NSLog(@"~~~~def~~~~~~%@", cachesDocPath);
    return mArray;
}
@end
